package com.controller;

import com.model.Param;
import com.model.Result;
import com.validator.ValidateField;
import com.validator.ValidateGroup;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by hc on 2017/5/22.
 */
@RestController
@RequestMapping(value = "/value")
public class TestController {

    @ValidateGroup(fields = {
            @ValidateField(index = 0, notNull = true, showName = "a 符号a")
    })
    @RequestMapping(value = "/test")
    public Result test(String a){
        return new Result<>("", true, a);
    }

    @ValidateGroup(fields = {
            @ValidateField(index = 0,filedName = "value", notNull = true, showName = "value 属性value")
    })
    @RequestMapping(value = "/param", method = RequestMethod.POST)
    public Result param(@RequestBody Param param){
        return new Result<>("", true, param.getValue());
    }

}
